package com.xiaoran.RMQ_1.test6_Direct_exchange;

import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;
import com.xiaoran.RMQ_1.utlis.RabbitMqUtils;

import java.util.Scanner;

public class Direct_exchange_Producer {
    public static final String EXCHANGE_NAME="direct_logs";
    public static void main(String args[]) throws  Exception{
        Channel channel= RabbitMqUtils.getChannel();
        channel.exchangeDeclare(EXCHANGE_NAME,BuiltinExchangeType.DIRECT);

        Scanner scanner=new Scanner(System.in);
        while (scanner.hasNext()){
            String message =scanner.next();
            channel.basicPublish(EXCHANGE_NAME,"info",null,message.getBytes());
            System.out.println("生产者发出的消息是："+message);
        }
    }
}
